import BuffUtil from '@/BuffUtil';

import ItemUtil from '@/ItemUtil';
import RandomUtil from '@/RandomUtil';
import BaseUtil from '@/BaseUtil';
import ArrayUtil from '@/ArrayUtil';
export default class Item_刚毛尖刺 {
    static id = 'C004';
    static 名称: string = '刚毛尖刺';
    static 描述: string = '攻速提升';
    static 图标: string = 'ReplaceableTextures\\CommandButtons\\BTNQuillSpray.blp';
    static buffId: string = 'buff_item_gangmaojianci';
    static cooldowns: unit[] = [];
    static buffType: AppBuffType = {
        id: 'buff_item_gangmaojianci',
        name: Item_刚毛尖刺.名称,
        ubertip: Item_刚毛尖刺.描述,
        art: Item_刚毛尖刺.图标,
        dur: 5,
        attribute: {
            attackSpd_p: 2,
        },
        targetAttach: 'lefthand',
        targetArt: 'Abilities\\Spells\\Orc\\Bloodlust\\BloodlustTarget.mdl',
    };
    constructor() {
        BuffUtil.registerBuffType(Item_刚毛尖刺.buffType);
        EventManager.onTakeAttack(Item_刚毛尖刺.spellEffect);
    }
    static spellEffect(d: DamageEventData) {
        let u = d.source;
        if (!ItemUtil.isUnitHasItem(u, Item_刚毛尖刺.id)) return;
        if (Item_刚毛尖刺.cooldowns.includes(u)) return;
        let r = RandomUtil.randomPercent();
        if (r > 0.22) return;
        Item_刚毛尖刺.cooldowns.push(u);
        DamageSystemInstance.applyPhysicalDamage(u, u, 200);
        BuffUtil.addBuff(u, Item_刚毛尖刺.buffId, u);
        BaseUtil.runLater(6, () => {
            ArrayUtil.removeElement(Item_刚毛尖刺.cooldowns, u);
        });
    }
}
